class MapSort {
  static Map<String, dynamic> mapSort(Map<String, dynamic> map) {
    List<String> keys = map.keys.toList();
    keys.sort((a, b) {
      List<int> a1 = a.codeUnits;
      List<int> b1 = b.codeUnits;
      for (int i = 0; i < a1.length; i++) {
        if (b1.length <= i) {
          return 1;
        }
        if (a1[i] > b1[i]) {
          return 1;
        } else if (a1[i] < b1[i]) {
          return -1;
        }
      }
      return 0;
    });
    Map<String, dynamic> treeMap = {};
    for (var element in keys) {
      treeMap[element] = map[element];
    }
    return treeMap;
  }
}
